home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 43.zip / Sources C - WorkDisk IV.adf / vertbinterrupt.c < prev   
C/C++ Source or Header  |  1987-02-15  |  875b  |  42 lines

  1. #include "exec/types.h"
  2. #include "exec/memory.h"
  3. #include "exec/interrupts.h"
  4. #include "hardware/custom.h"
  5. #include "hardware/intbits.h"
  6.  
  7. struct Interrupt *VertBIntr;
  8. long count;
  9.  
  10. void VertBServer()
  11. {
  12. int_start();
  13. count++;
  14. int_end();
  15. }
  16.  
  17. main()
  18. {
  19.  
  20. VertBIntr= (struct Interrupt *)AllocMem((LONG)sizeof(struct Interrupt),MEMF_PUBLIC);
  21. if(VertBIntr==0)
  22. {
  23.  puts("Not enough memory for interrupt server!\n");
  24.  exit(100);
  25. }
  26.  
  27. VertBIntr->is_Node.ln_Type=NT_INTERRUPT;
  28. VertBIntr->is_Node.ln_Pri=-60;
  29. VertBIntr->is_Node.ln_Name="VertB-example";
  30. VertBIntr->is_Data=(APTR)&count;
  31. VertBIntr->is_Code=(VOID(*)())VertBServer;
  32.  
  33. AddIntServer(INTB_VERTB,VertBIntr);
  34. puts("Type q to quit... reports how many vblanks since start\n");
  35. while(getchar()!='q');
  36.  
  37. RemIntServer(INTB_VERTB,VertBIntr);
  38. printf("%ld vertical blanks counted!\n",count);
  39. FreeMem(VertBIntr,(LONG)sizeof(struct Interrupt));
  40. }
  41.  
  42.